package com.lyy.king.common.core.domain;

public class BasePageQuery {
    /**
     * 当前页数
     */
    private Integer pageIndex = 1;
    /**
     * 每页记录数
     */
    private Integer pageSize = 10;

    /**
     * 数据索引开始
     * @return
     */
    private Integer startLimit = 0;

    /**
     * 数据索引结束
     * @return
     */
    private Integer entLimit = 10;


    public Integer getEntLimit() {
        return entLimit;
    }

    public Integer getStartLimt() {
        return startLimit;
    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {

        this.pageIndex = pageIndex;
        calculateLimit();

    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
        calculateLimit();

    }

    private void calculateLimit(){
        if(pageIndex < 1){
            throw new RuntimeException("开始页不能小于1");
        }
        startLimit =  (pageIndex-1) * pageSize;
        entLimit = startLimit + pageSize;
    }
}
